package com.yao.myioc.registry.support;

import com.yao.myioc.registry.SingletonBeanRegistry;

import java.util.HashMap;
import java.util.Map;

/**
 * 单例对象管理接口的实现类
 * @author Henry Yao
 */
public class DefaultSingletonBenRegistry implements SingletonBeanRegistry {
    /**
     * 单例bean缓存
     */
    private Map<String, Object> singletons = new HashMap<>();

    @Override
    public Object getSingleton(String beanName) {
        return singletons.get(beanName);
    }

    @Override
    public void addSingleton(String name, Object bean) {
        singletons.put(name, bean);
    }
}
